<template>
    <div class="bigdiv">

        <van-divider :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }">
            {{ number }}
        </van-divider>
        <van-form>

            <van-cell-group inset>
                <van-field v-model="changefrom.problemRecord" label-width="100" rows="5" label-align="top" clearable
                    autosize label="问题记录:" type="textarea" placeholder="请输入" />
            </van-cell-group>
        </van-form>

        <van-button @click="changeok" type="primary" block>检查完成</van-button>
        <br />
        <van-button @click="changeok1" type="primary" block>等待处理</van-button>
        <br />
        <van-button @click="changeok2" type="primary" block>清空检查信息</van-button>
        <br />
        <van-button @click="gxfather('addEvent', false)" type="primary" block>关闭</van-button>
    </div>
</template>

<script setup>
import { defineProps, onMounted, defineEmits, ref, } from 'vue';
import { getjieshoulist, submitSQ, changelist } from "../../sevce/user";
import { showToast } from 'vant';
import { showNotify } from 'vant';
const props = defineProps({
    number: String,
    id: Number,
    equipmentName: String,
    entryName: String,
    model: String,
    realDepartment: String,
    serialNumber: String,
    projectLeader: String,
    applicationTime: String,
    position: String,
    model: String,
    customer_drive: String,
    usageSituation: String,
    equipment_status: String,
    process_status: String,
    remarks: String,
    realDepartment: Number,
    processStatus: Number,
    problemRecord: String,//问题记录
    checkStatus: Number,//检查状态
    checksTime: Date,//检查时间
})
//向父组件传参,关闭本窗口
// const closemine = defineEmits(['addEvent']) //addEvent是父元素里面的一个函数方法，通过这个方法传参

//检查信息
const changefrom = ref({
    id: props.id,
    start: 0,
    checkStatus: 0,
    problemRecord: '',

})
//检查确认
function changeok() {
    changefrom.value.checkStatus = 2
    changelist(changefrom.value).then((res) => {
        if (res.data == 0) {
            showToast('失败')
        } else if (res.data == 1) {
            showToast('成功')
            gxfather()
        }
    })

}
//待处理
function changeok1() {
    changefrom.value.checkStatus = 3
    changelist(changefrom.value).then((res) => {
        if (res.data == 0) {
            showToast('失败')
        } else if (res.data == 1) {
            showToast('成功')
            gxfather()
        }
    })

}
//清空
function changeok2() {

    changefrom.value.checkStatus = 1
    changefrom.value.problemRecord = ''
    changelist(changefrom.value).then((res) => {
        if (res.data == 0) {
            showToast('失败')
        } else if (res.data == 1) {
            showToast('成功')
            gxfather()
        }
    })
}
//初始赋值
function fz() {
    changefrom.value.id = props.id
    changefrom.value.problemRecord = props.problemRecord
}
//修改完成更新数据
let emit = defineEmits(['addEvent'])
function gxfather() {
    emit('addEvent');
}
onMounted(() => {
    // console.log(props)
    fz()

})
</script>

<style lang="scss" scoped>
.bigdiv {
    margin: 0 10px 0 30px;
}
</style>